package cn.meebook.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;

import org.springframework.data.annotation.CreatedDate;

/**
 * 圈子，即有同类型知识、能力、兴趣取向，且有核心成员和管理员的组织。
 * 
 * @author 王帆
 *
 */
@Entity
public class Circle implements Serializable {

	private static final long serialVersionUID = -3050891295381963222L;
	
	@Id
    @GeneratedValue(strategy=GenerationType.AUTO)
	private Long  id;
	
	private String name;
	
	@ManyToOne
	private Meeker creator;
	
	@ManyToMany(mappedBy="circles")
	private List<Meeker> members;
	
	@CreatedDate
	private Date createDate;
	
	public Circle() {
		this.members = new ArrayList<Meeker>();
		this.createDate = new Date();
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Meeker getCreator() {
		return creator;
	}

	public void setCreator(Meeker creator) {
		this.creator = creator;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public List<Meeker> getMembers() {
		return members;
	}

	public void setMembers(List<Meeker> members) {
		this.members = members;
	}

	@Override
	public String toString() {
		return "Circle [id=" + id + ", name=" + name + "]";
	}

}
